#ifndef H_RCGD_EBCMD_H
#define H_RCGD_EBCMD_H

/*--------------------------------------*/
/*             E/B Tx command           */
/*--------------------------------------*/
#define NUM_OF_EBTX_MESSAGE 23

#define eSELFTEST       	0
#define ePSDM          		1
#define ePHM       			2
#define eTIMEMODE       	3
#define eGMTOFFSET      	4
#define eDATE          		5
#define eTIME          		6
#define ePHP           		7
#define eANTDLY        		8
#define eLEAP          		9
#define eDEFAULT       		10
#define eTRAIM         		11
#define eRECEIVERID	   		12
#define eUTC_OFFSET    		13
#define eMASK_ANGLE			14
#define eSAT_STATUS			15
#define eAT_CORRECTION		16
#define eSET_USER_DATUM		17
#define eSELECT_DATUM		18
#define eDEBUG_DISPLAY		19
#define eTHR_DETECT			20
#define eTHR_UNLOCK			21
#define e1PPS_OFFSET		22


/*------------------------------------
    E/B Rx command
--------------------------------------*/
#define NUM_OF_EBRX_MESSAGE	26

#define EBRX_TOD             0
#define EBRX_GMT_OFFSET      1
#define EBRX_DATE            2
#define EBRX_LATITUDE        3
#define EBRX_LONGITUDE       4
#define EBRX_HEIGHT          5
#define EBRX_PHP             6
#define EBRX_PHM             7
#define EBRX_TIME_MODE       8
#define EBRX_CABLEDELAY      9
#define EBRX_ALMANAC_IN      10
#define EBRX_ALMANAC_OUT     11
#define EBRX_LEAPSEC         12
#define EBRX_SETTODEFAULT    13
#define EBRX_RECEIVERID      14
#define EBRX_PSDM            15
#define EBRX_TRAIM           16
#define EBRX_SELFTEST        17
#define EBRX_POWERFAILURE    18
#define EBRX_UTC_OFFSET		 19


#define EBRX_MASK_ANGLE		20
#define EBRX_SAT_STATUS		21
#define EBRX_AT_CORRECTION 	22
#define EBRX_SET_USER_DATUM	23
#define EBRX_SELECT_DATUM	24

#define EBRX_1PPS_OFFSET	25

#define TRAIM_SOL_OK			0
#define	TRAIM_SOL_ALARM			1
#define TRAIM_SOL_UNKNOWN		2

#define TRAIM_STATUS_ISOLATION	0
#define TRAIM_STATUS_DETECTION	1
#define TRAIM_STATUS_NEITHER	2





/*=================================================================*/
/*                          EBCMD.C                                */
/*=================================================================*/
typedef struct EBR{
    BYTE Name[2];
    //kang BYTE  Length;
	WORD  Length;
    char  Command;
} EBR_;


typedef struct EBT {
    BYTE  Name[2];
    WORD  Length;
} EBT_;



/* Position Hold Position */
#define disablePHM  0
#define enablePHM   1
#define enablePHP   2



extern char month[12];


/* Initialization */
extern void Init_EBRxMessage();
extern void Init_EBTxMessage();

/* EB Tx Handling */
extern void RequestEB(int);

extern void EB_Event_Handling(void);

/* EB Rx Handling */
extern int EBGetCommandID(BYTE *,WORD);
extern void EBHandleIt(int,int,BYTE *);

/* EB Tx Procedures */
extern void SetGMTOFFSET(char,char);
extern void SetDATE(WORD,BYTE,BYTE);
extern void SetTIME(BYTE,BYTE,BYTE);
extern void SetPOSITIONHOLD();
extern void SetANTDLY(long);
extern void Set1PPSoffset(long);

extern char	Setting_GMTOFFSET();
extern char	Setting_ANTDLY();
extern char	Setting_POSITION();
extern char	Setting_EBID();
extern char	Setting_TIMEMODE();


extern char 	Enable_PSDM();
extern char 	Enable_PHM();
extern char 	Disable_PHM();
extern char 	Enable_PHP();
extern void traim_1pps(char);

extern char start_traim_query;
extern char rcv_debug_display;

extern void SetRcvDebug(unsigned char mode);
extern void SetRcvThrDetect(unsigned char pit_1ms,unsigned char pit_4ms,unsigned char pit_20ms);
extern void SetRcvThrUnlock(unsigned char pit_1ms,unsigned char pit_4ms,unsigned char pit_20ms);


extern unsigned char psdm_watch_val[2][100];
extern int year_err_cnt;

char Enable_MASK();
char Enable_SATSTATUS();
int Enable_TRAIM();
void Init_EBCMD(void);
void SetLEAPSECOND(char mode);
void SetMASKANGLE(unsigned char angle);
void SetPSDM(char mode);
void SetUTCOFFSET(char mode);

#endif

